<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改药品管理')" />
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: jquery-smartwizard-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: summernote-css"/>
    <link rel="stylesheet" href="/js/kindeditor/themes/default/default.css"/>
    <script charset="utf-8" src="/js/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="/js/kindeditor/lang/zh-CN.js"></script>
    <style>
        .add_div{
            margin-top: 6px;
            display: block;
            width: 40px;
            height: 20px;
            background: #cccccc;
            color: #0C0C0C;
            cursor: pointer;
        }
        .form-horizontal {
            width: 88vw !important;
        }

        .separator {
            border-bottom: 2px dotted;
            width: 20px;
            height: 1px;
            color: #02B7CA;
            flex: auto;
        }

        .title {
            margin-right: 1vw;
        }

        .sw > .tab-content {
            overflow: inherit;
        }

        .progress {
            display: none;
        }

        .emptyAdd {
            visibility: visible !important;
        }

        .emptyMove {
            visibility: hidden;
        }

        .drug-div {
            position: fixed;
            top: 100px;
            right: 0;
            width: 130px;
            color: #000;
            display: flex;
            flex-direction: column;
        }

        .drug-div a {
            white-space: nowrap;
            font-size: 14px;
            line-height: 26px;
            position: relative;
            padding-left: 16px;
        }

        .drug-div a:before {
            content: "";
            width: 2px;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            background: #DDE8EB;
        }

        .drug-div .actidiv {
            color: #02B7CA;
        }

        .drug-div .rightlist {
            display: inline-block;
            width: 76px;
        }

        .toggle-switch.switch-solid span {
            height: 16px;
            width: 32px;
        }

        .toggle-switch span:after {
            height: 16px;
            width: 16px;
            left: -2px;
        }

        .switch-solid input:checked ~ span:after {
            background-color: #fff;
            color: #33cabb;
        }

        .toggle-switch input:checked ~ span:after {
            left: calc(100% - 12px);
        }

        .drug-div i {
            color: #02B7CA;
            font-size: 12px;
            cursor: pointer;
        }

        .drug-div .actidiv:after {
            content: "";
            width: 2px;
            height: 16px;
            position: absolute;
            left: 0;
            top: 5px;
            background: #02B7CA;
        }

        /*  药品规格信息样式*/
        #bootstrap-table th {
            min-width: 58px;
        }

        .select-table table {
            table-layout: fixed;
        }
    </style>
</head>
<script src="../static/js/xm-select.js" th:src="@{/js/xm-select.js}"></script>

<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">基本信息</a>
        </li>
        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">其他信息</a>
        </li>
    </ul>
    <div class="tab-content" th:object="${drug}">
        <!--基本信息-->
        <div id="tab-1" class="tab-pane active" style="padding: 20px" >
            <form class="form-horizontal m" id="form-drug-edit" >
                <input name="id" th:field="*{id}" type="hidden">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">中文名称</label>
                        <div class="col-sm-10">
                            <input name="name" th:field="*{name}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">英文名称</label>
                        <div class="col-sm-10">
                            <input name="nameEn" th:field="*{nameEn}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">产品名称</label>
                        <div class="col-sm-10">
                            <input name="productName" th:field="*{productName}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">别称</label>
                        <div class="col-sm-10">
                            <input name="alias" th:field="*{alias}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">价格</label>
                        <div class="col-sm-10">
                            <input name="price" th:field="*{price}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">原价</label>
                        <div class="col-sm-10">
                            <input name="originalPrice" th:field="*{originalPrice}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">疾病</label>
                        <div class="col-sm-10">
                            <div id="drugDisease"></div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">厂家</label>
                        <div class="col-sm-10">
                            <div id="selectFactory"></div>
                        </div>
                    </div>
                </div>
                <div id="targetDiv">

                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">主图</label>
                    <div class="col-sm-11">
                        <input type="hidden" th:value="*{icon}" name="url">
                        <div class="file-loading">
                            <input class="form-control file-upload"  id="icon" name="file" type="file">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">适应症简介</label>
                    <div class="col-sm-11">
                        <textarea name="introduction" class="form-control">[[*{introduction}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">完整规格</label>
                        <div class="col-sm-10">
                            <input name="specifications" th:field="*{specifications}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">价格规格</label>
                        <div class="col-sm-10">
                            <input name="priceSpecifications" th:field="*{priceSpecifications}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">剂型</label>
                        <div class="col-sm-10">
                            <input name="dosage" th:field="*{dosage}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">有效期</label>
                        <div class="col-sm-10">
                            <input name="periodOfValidity" th:field="*{periodOfValidity}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">制造商</label>
                        <div class="col-sm-10">
                            <input name="manufacturer" th:field="*{manufacturer}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">储存方法</label>
                    <div class="col-sm-11">
                        <textarea name="storagecondition" class="form-control">[[*{storagecondition}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">标题</label>
                        <div class="col-sm-10">
                            <input name="title" th:field="*{title}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">关键词</label>
                        <div class="col-sm-10">
                            <input name="keywords" th:field="*{keywords}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">描述</label>
                    <div class="col-sm-11">
                        <textarea name="description" class="form-control">[[*{description}]]</textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">温馨提示</label>
                    <div class="col-sm-11">
                        <textarea name="warmPrompt" class="form-control">[[*{warmPrompt}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">参考资料</label>
                    <div class="col-sm-11">
                        <textarea name="referenceMaterial" class="form-control">[[*{referenceMaterial}]]</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">信息来源</label>
                    <div class="col-sm-11">
                        <textarea name="informationSources" class="form-control"></textarea>
                    </div>
                </div>
            </form>
        </div>

        <!--其他信息-->
        <div id="tab-2" class="tab-pane " style="padding: 20px" th:with="type=${@dict.getType('drug_type')}">
            <form class="form2 form-horizontal m"
                  th:id="'form-drug-other'+${dict.dictValue}"  th:each="dict : ${type}">
                <div class="formadd2div" th:id="'formadd2div'+${dict.dictValue}">
                    <h4 class="form-header h4">[[${dict.dictLabel}]]</h4>
                    <input type="hidden" name="type" th:value="${dict.dictValue}"  class="form-control" >
                    <input type="hidden" th:id="'drugotherli'+${dict.dictValue}" name="id" class="drugotherId">
                    <input type="hidden" th:id="'drugotherdrugid'+${dict.dictValue}" name="drugId" class="drugotherId">
                    <div class="form-group row">
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">网页标题</label>
                            <div class="col-sm-10">
                                <input th:id="'pagetitle'+${dict.dictValue}" type="text" name="webpagetitle"
                                       class="form-control"
                                       placeholder="请输入文本">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-2 control-label">网页关键字</label>
                            <div class="col-sm-10">
                                <input th:id="'pagekeywords'+${dict.dictValue}" type="text" name="webpagekeywords"
                                       class="form-control" placeholder="请输入文本">
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-sm-1 control-label">网页描述</label>
                        <div class="col-sm-11">
                                <textarea th:id="'pagedescription'+${dict.dictValue}" type="text" name="webpagedescription" class="form-control"
                                          placeholder="请输入文本"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-1 control-label">[[${dict.dictLabel}]]</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <textarea th:id="'summernoteDiv'+${dict.dictValue}" name="content" type="text/plain"></textarea>

                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: jquery-smartwizard-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: summernote-js"/>
<script src="/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charset="utf-8"></script>
<script th:inline="javascript">
    //药品其他信息类型TDK字典
    var dictarr = [[${@dict.getType('drug_type')}]];
    //疾病
    var diseaseData = [];
    var diseaseArr = [];
    var backDisease = [];
    //药企
    var factoryArr = [];
    var factoryData = [];
    var backFactory = [];
    //药品数据
    var drugthings = [[${drug}]]
    var prefix = ctx + "ydz/drug"
    // $("#form-drug-edit").validate({
    //     focusCleanup: true
    // });
    $(document).ready(function () {

        parent.$('body').find('.layui-layer-max:not(.layui-layer-maxmin)').click()
        //回显疾病多选
        if (null != drugthings.drugDiseaseList){
            drugthings.drugDiseaseList.forEach(item=>{
                let obj = {}
                obj.id=item.id,
                obj.diseaseId =item.diseaseId
                obj.pid = item.pid
                obj.name = item.name
                diseaseArr.push(obj)
                backDisease.push(item.diseaseId.toString())
                getTargetList(obj)
            })

        }
        if(null != drugthings.drugEnterpriseList){
            backfactory = drugthings.drugEnterpriseList;
            backfactory.forEach(function (item){
                let obj = {
                    id:item.id,
                    enterpriseId:item.enterpriseId,
                    name:item.enterpriseName
                }
                factoryArr.push(obj)
                backFactory.push(obj)

            })
        }

        //加载疾病下拉
        $.ajax({
            url: "/api/common/selectNewDisease",
            type: "get",
            success: res => {
                alldis = res.data
                for (let i = 0; i < alldis.length; i++){
                    let val = {}
                    val.name = alldis[i].name
                    val.diseaseId = alldis[i].id
                    val.pid = alldis[i].pid
                    diseaseData.push(val)
                }
                initXmSelect()
            }
        })
        //加载厂家下拉
        $.ajax({
            url: "/ydz/enterprise/list",
            type: "post",
            success: res => {
                var factoryList = res.rows
                for (let i = 0; i < factoryList.length; i++){
                    let val = {}
                    val.name = factoryList[i].name
                    val.enterpriseId = factoryList[i].id
                    factoryData.push(val)
                }
                factorySelect()
            }
        })
    })



    function submitHandler() {

        var jsons = {};
        // 清除所有 select 元素的选中值
        let formData = $('#form-drug-edit').serializeArray()

        $.each(formData, function (k, v) {
            jsons[v.name] = v.value;
        });
        var trueotherarr = []
        if ($.validate.form()) {
            //其他信息组装

            let otherarr = []
            dictarr.forEach(function (item){
                let formId = 'form-drug-other'+item.dictValue
                let otherFormData = $('#' + formId).serializeArray();
                otherarr.push(otherFormData)
            })
            otherarr.forEach(function (item){

                    let otherjson = {}
                    $.each(item, function (k, v) {
                        otherjson[v.name] = v.value;
                    });
                    trueotherarr.push(otherjson)

            })
            //药品靶点组装·
            let drugTargetArr = [];
            let checkboxes = document.querySelectorAll('input[name="targetObj"]:checked');
            // 循环获取选中的值
            checkboxes.forEach(function(checkbox) {
                let checkboxValue = checkbox.value; // 获取复选框的值
                let diseaseIdInput = checkbox.closest('div').querySelector('input[name="diseaseId"]'); // 获取同级的diseaseId输入框
                let diseaseIdValue = diseaseIdInput ? diseaseIdInput.value : ''; // 获取diseaseId输入框的值
                var idInput = checkbox.parentElement.querySelector('input[name="targetId"]');
                let idValue = idInput ? idInput.value : '';
                let obj = {
                    id: idValue,
                    targetId: checkboxValue,
                    diseaseId: diseaseIdValue
                };
                // 将对象添加到结果数组中
                drugTargetArr.push(obj);
            });

            //药品其他信息
            jsons['drugOtherList'] = trueotherarr

            //药企信息
            const factoryArray = factoryArr.map(item1 => {
                // 查找factoryArr中enterpriseId相同的元素
                const match = drugthings.drugEnterpriseList.find(item2 => item2.enterpriseId === item1.enterpriseId);
                if (match) {
                    // 如果有相同enterpriseId的对象，则合并两个对象
                    return { ...item1, ...match };
                }
                return item1;  // 没有匹配项则返回原来的对象
            }).concat(drugthings.drugEnterpriseList.filter(item2 =>
                !factoryArr.some(item1 => item1.enterpriseId === item2.enterpriseId)
            ));

            jsons['drugEnterpriseList'] = factoryArray
            //药品疾病
            const diseaseArray = diseaseArr.map(item1 => {
                // 查找diseaseArray中diseaseId相同的元素
                const match = drugthings.drugDiseaseList.find(item2 => item2.diseaseId === item1.diseaseId);
                if (match) {
                    // 如果有相同diseaseId的对象，则合并两个对象
                    return { ...item1, ...match };
                }
                return item1;  // 没有匹配项则返回原来的对象
            }).concat(drugthings.drugDiseaseList.filter(item2 =>
                !diseaseArr.some(item1 => item1.diseaseId === item2.diseaseId)
            ));
            jsons['drugDiseaseList'] = diseaseArray

            //药品靶点
            const drugTargetArray = drugTargetArr.map(item1 => {
                // 查找drugTargetArray中diseaseId相同的元素
                const match = drugthings.drugTargetList.find(item2 => item2.diseaseId === item1.diseaseId);
                if (match) {
                    // 如果有相同diseaseId的对象，则合并两个对象
                    return { ...item1, ...match };
                }
                return item1;  // 没有匹配项则返回原来的对象
            }).concat(drugthings.drugTargetList.filter(item2 =>
                !drugTargetArr.some(item1 => item1.diseaseId === item2.diseaseId)
            ));
            jsons['drugTargetList'] = drugTargetArray

            save(prefix + "/add", JSON.stringify(jsons));
        }
    }
    function save(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            headers: {
                'Content-Type': 'application/json;charset=utf8'
            },
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍候...");
                $.modal.disable();
            },
            success: function (result) {
                if (typeof callback == "function") {
                    callback(result);
                }
                $.operate.successCallback(result);
            }
        };
        $.ajax(config)
    }

    //疾病下拉
    function initXmSelect(){
        xmSelect.render({
            el: '#drugDisease',
            checkbox: true,
            repeat: false,
            autoRow: true,
            filterable: true,
            prop: {name: 'name', value: 'diseaseId',pid:'pid'},
            initValue: backDisease,//回显
            height: '200px',
            tips: '请选择',
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                expandedKeys: [-3],
                strict: false,
            },
            data: function () {
                return diseaseData
            },
            on: function (data) {
                diseaseArr = data.arr;//arr:  当前多选已选中的数据
                changeDisease(data.change,data.isAdd);
            },
        });
    }

    function changeDisease(obj,flag) {
        var diseaseBean={}
        obj.forEach(item => {
            diseaseBean = item;
        });
        //添加新标签时
        if(flag){
            getTargetList(diseaseBean);
        }else{
            //查找回显集合中的元素，有则更改有效性，没有则忽略
            const disease = drugthings.drugDiseaseList.find(item => item.diseaseId === diseaseBean.diseaseId);
            if (disease) {
                disease.delFlag = "1";  // 修改有效性为1,（无效，用作删除）
            }
            //根据疾病id删除靶点div代码块
            var element = document.getElementById('disease_div_'+diseaseBean.diseaseId);
            if (element) {
                element.remove();
            }

            //根据疾病id更改靶点有效性为无效
            if(null != drugthings.drugTargetList){
                drugthings.drugTargetList.forEach(item => {
                    if (item.diseaseId === diseaseBean.diseaseId) {
                        item.delFlag = 1;  // 设置 delFlag 为 1
                    }
                });
            }

        }
    }

    //获取疾病下的靶点集合
    function getTargetList(data){
        $.ajax({
            url: "/ydz/diseaseTarget/list",
            type: "post",
            data: {diseaseId:data.diseaseId},
            success: res => {
                targetList = res.rows
                let html="";
                html+="<div className='form-group' id = 'disease_div_"+data.diseaseId+"'>"
                    +"<label className='col-sm-1 control-label '>"+data.name+"</label>"
                    +"<div className='col-sm-11'>";
                    targetList.forEach(item => {
                        //初始遍历为false也就是说不选中，反之则为选中
                        var flag = false;
                        //药品标签id
                        var tid = "";
                        if(null != drugthings.drugTargetList){
                            drugthings.drugTargetList.forEach(target=> {
                                if (item.id === target.targetId) {
                                    flag = true
                                    tid = target.id
                                }
                            })
                        }
                     html+="<label class='check-box'>"
                         +"<input  type='hidden' name='targetId' type='checkbox' value='"+tid+"'  >"
                        +"<input  type='hidden' name='diseaseId' type='checkbox' value='"+data.diseaseId+"'  >"
                        +"<input onchange='checkTarget(this)'  name='targetObj' type='checkbox' value='"+item.id+"' text='"+item.name+"' " + (flag ? "checked='checked'" : "") + "  >"
                        +"<span> "+item.name+" </span>"
                        +"</label>";
                    });
                html+="</div>"

                    +"</div>";
                // $("#targetDiv").append(html);
            }
        })
    }

    function checkTarget(e){
        if (!e.checked) {
            const target = drugthings.drugTargetList.find(item => item.targetId.toString() === e.value);
            if (target) {
                target.delFlag = "1";  // 修改有效性为1,（无效，用作删除）
            }
        }
    }

    //药企下拉
    function factorySelect(){
        xmSelect.render({
            el: '#selectFactory',
            checkbox: true,
            repeat: false,
            autoRow: true,
            filterable: true,
            prop: {name: 'name', value: 'enterpriseId'},
            initValue: backFactory,//回显
            height: '200px',
            tips: '请选择',
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                expandedKeys: [-3],
                strict: false,
            },
            data: function () {
                return factoryData
            },
            on: function (data) {
                factoryArr = data.arr;//arr:  当前多选已选中的数据
                changeFactory(data.change,data.isAdd);
            },
        });
    }

    function changeFactory(obj,flag) {

        var factoryBean={}
        obj.forEach(item => {
            factoryBean = item;
        });
        //删除新标签时
        if(!flag && null != drugthings.drugEnterpriseList){
            //查找回显集合中的元素，有则更改有效性，没有则忽略
            const factory = drugthings.drugEnterpriseList.find(item => item.enterpriseId === factoryBean.enterpriseId);
            if (factory) {
                factory.delFlag = "1";  // 修改有效性为1,（无效，用作删除）
            }
        }
    }


    $(function() {
        $('.summernote').summernote({
            lang: 'zh-CN',
            dialogsInBody: true,
            callbacks: {
                onChange: function(contents, $edittable) {
                    $("input[name='" + this.id + "']").val(contents);
                },
                onImageUpload: function(files) {
                    var obj = this;
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        type: "post",
                        url: ctx + "common/upload",
                        data: data,
                        cache: false,
                        contentType: false,
                        processData: false,
                        dataType: 'json',
                        success: function(result) {
                            if (result.code == web_status.SUCCESS) {
                                $('#' + obj.id).summernote('insertImage', result.fileName);
                            } else {
                                $.modal.alertError(result.msg);
                            }
                        },
                        error: function(error) {
                            $.modal.alertWarning("图片上传失败。");
                        }
                    });
                }
            }
        });
    });

    $(".file-upload").each(function (i) {
        var val = $("input[name='" + this.id + "']").val()
        if (val==""){
            $(".file-upload").fileinput({
                uploadUrl: ctx + 'common/upload',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        }else{
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        }
    });

    var editors = {};
    let gudingstr = "ue"
    dictarr.forEach(function (item){
        editors[gudingstr + item.dictValue] = UE.getEditor('summernoteDiv'+item.dictValue, {
            autoHeightEnabled: false,//是否自动长高
            autoFloatEnabled: true,//是否保持toolbar的位置不动
            scaleEnabled:true,//是否可以拉伸长高
            initialFrameWidth: 'auto',//初始化编辑器宽度
            initialFrameHeight:300,//初始化编辑器高度
        });
        if(drugthings.drugOtherList.length > 0){
            for (var i = 0; i < drugthings.drugOtherList.length; i++) {
                if (drugthings.drugOtherList[i].type==item.dictValue){
                    let content =drugthings.drugOtherList[i].content
                    $(`#${'pagetitle'+item.dictValue}`).val(drugthings.drugOtherList[i].webpagetitle)
                    $(`#${'pagekeywords'+item.dictValue}`).val(drugthings.drugOtherList[i].webpagekeywords)
                    $(`#${'pagedescription'+item.dictValue}`).val(drugthings.drugOtherList[i].webpagedescription)
                    $(`#${'drugotherli'+item.dictValue}`).val(drugthings.drugOtherList[i].id)
                    $(`#${'drugotherdrugid'+item.dictValue}`).val(drugthings.drugOtherList[i].drugId)
                    editors[gudingstr + item.dictValue].ready(function (){
                        editors[gudingstr + item.dictValue].execCommand("insertHtml",content);//富文本回显
                    })
                }else{
                    editors[gudingstr + item.dictValue].ready(function (){
                    })
                }
            }
        }else{
            editors[gudingstr + item.dictValue].ready(function (){
            })
        }
    })
    var ue = UE.getEditor('content', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled:true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight:300,//初始化编辑器高度
    });
    ue.ready(function (){
        ue.execCommand("insertHtml",drugthings.content);//富文本回显
    })

    var information = UE.getEditor('information', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    information.ready(function () {
    })

    var adaptationdisease = UE.getEditor('adaptationdisease', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    adaptationdisease.ready(function () {
    })

    var therapeuticEffect = UE.getEditor('therapeuticEffect', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    therapeuticEffect.ready(function () {
    })

    var usageanddosage = UE.getEditor('usageanddosage', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    usageanddosage.ready(function () {
    })

    var announcements = UE.getEditor('announcements', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    announcements.ready(function () {
    })

    var reaction = UE.getEditor('reaction', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    reaction.ready(function () {
    })
</script>
</body>
</html>